<style>
    html{
        background-color: #f2f2f2;
    }
    .content-body{
        background-color: transparent;
    }
    /* 卡片面板 */
    .layui-card{margin-bottom: 10px; border-radius: 2px; background-color: #fff; box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);}
    .layui-card:last-child{margin-bottom: 0;}
    .layui-card-header{position: relative; height: 42px; line-height: 42px; padding: 0 15px; border-bottom: 1px solid #f6f6f6; color: #333; border-radius: 2px 2px 0 0; font-size: 14px;}
    .layui-card-body{position: relative; padding: 10px 15px; line-height: 24px;}
    th,td{
        text-align: center;
    }
</style>

<div class="container-fluid">

    <div class="row layui-card">
        <div class="layui-card-body">
            <a href="{:url('index/index')}">主页</a>
            <span>/</span>
            <span>导出上报财政部</span>
        </div>
    </div>

    <div class="row layui-card">
        <div class="layui-card-header" style="height: 45px;">
            <div class="form-inline">
                <label>开始日期</label>
                <input id="startDate" class="form-control" style="width: 120px;background-color: white">
                &nbsp;&nbsp;&nbsp;&nbsp;
                <label>结束日期</label>
                <input id="endDate" class="form-control" style="width: 120px;background-color: white">
                &nbsp;&nbsp;&nbsp;&nbsp;
                <label>上级单位</label>
                <select id="belong" class="form-control" style="width: 120px;">
                    <option value="000">天津大学</option>
                    <option value="407">附中</option>
                    <option value="416">附小</option>
                    <option value="406">内燃所</option>
                </select>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <label>资产大类</label>
                <select id="type" class="form-control" style="width: 120px;">
                    <option value="1">土地</option>
                    <option value="2">设备</option>
                    <option value="3">家具</option>
                    <option value="4">房屋构筑物</option>
                </select>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <button class="btn btn-info btn-sm" onclick="clickSearch()">查询</button>
                &nbsp;&nbsp;<button id="export" class="btn btn-success btn-sm" disabled onclick="clickExport()">导出</button>
            </div>
        </div>
        <div class="layui-card-body">
            <table id="list-table"></table>
        </div>
    </div>

</div>

<script>

    $(function () {
        $("#startDate").val("{$startDate}");
        $("#endDate").val("{$endDate}");
        $("#type").val("{$type}");
        $("#belong").val("{$belong}");
        $("#startDate").flatpickr();
        $("#endDate").flatpickr();

        var startDate = $("#startDate").val();
        var endDate = $("#endDate").val();
        var type = $("#type").val();
        var belong = $("#belong").val();
        if(type == '1'){
            $("#export").removeAttr("disabled");
            var h = $(window).height();
            $("#list-table").bootstrapTable({
                url:'getLandForCZB',
                method:'post',
                sidePagination: 'server',
                pagination:true,
                pageSize:20,
                pageList:[10,20,50],
                pageNumber:1,
                height:h - 210,
                columns:[{
                    title:'资产编号',
                    field:'LAND_NO',
                    sortable:true
                },{
                    title:'资产名称',
                    field:'LAND_NAME',
                    sortable:true
                },{
                    title:'资产分类代码',
                    field:'ASSET_TYPE_ID',
                    sortable:true
                },{
                    title:'资产分类名称',
                    field:'ASSET_TYPE_NAME',
                    sortable:true
                },{
                    title:'取得方式',
                    field:'GETTYPE_ID',
                    sortable:true
                },{
                    title:'取得日期',
                    field:'GET_DATE',
                    sortable:true
                },{
                    title:'采购组织形式',
                    field:'PURCHASE_ID',
                    sortable:true
                },{
                    title:'产权形式',
                    field:'PROPERTYRIGHT_ID',
                    sortable:true
                },{
                    title:'权属性质',
                    field:'POWERTYPE',
                    sortable:true
                },{
                    title:'权属证明',
                    field:'OWNER_CERT',
                    sortable:true
                },{
                    title:'权属证号',
                    field:'OWNER_CERT_NO',
                    sortable:true
                },{
                    title:'坐落位置',
                    field:'LAND_AREA',
                    sortable:true
                },{
                    title:'原值',
                    field:'LAND_FEE',
                    sortable:true
                },{
                    title:'财政拨款',
                    field:'FINANCE_GET_FEE',
                    sortable:true
                },{
                    title:'事业收入',
                    field:'BUSINESS_GET_FEE',
                    sortable:true
                },{
                    title:'其中：预算外资金',
                    field:'BUSINESS_BUDGET_GET_FEE',
                    sortable:true
                },{
                    title:'其他资金',
                    field:'OTHER_FEE',
                    sortable:true
                },{
                    title:'土地面积（㎡）',
                    field:'LAND_SIZE',
                    sortable:true
                },{
                    title:'使用状况',
                    field:'STATUS',
                    sortable:true
                },{
                    title:'自用面积',
                    field:'SELF_SIZE',
                    sortable:true
                },{
                    title:'出借面积',
                    field:'BORROW_SIZE',
                    sortable:true
                },{
                    title:'出租面积',
                    field:'RENTAL_SIZE',
                    sortable:true
                },{
                    title:'对外投资面积',
                    field:'INVESTMENT_SIZE',
                    sortable:true
                },{
                    title:'担保面积',
                    field:'GUARANTEE_SIZE',
                    sortable:true
                },{
                    title:'其他面积',
                    field:'ELSE_SIZE',
                    sortable:true
                },{
                    title:'用途分类',
                    field:'USE_TYPE',
                    sortable:true
                },{
                    title:'净值',
                    field:'NET_VALUE',
                    sortable:true
                },{
                    title:'备注',
                    field:'REMARK',
                    sortable:true
                }],
                queryParams:function (params) {
                    params.startDate = startDate;
                    params.endDate = endDate;
                    return params;
                },
                responseHandler:function (res) {
                    console.log(res);
                    return res;
                }
            });
        }

        if(type == '2'){
            $("#export").removeAttr("disabled");
            var h = $(window).height();
            $("#list-table").bootstrapTable({
                url:'getFacilityForCZB',
                method:'post',
                sidePagination: 'server',
                pagination:true,
                pageSize:20,
                pageList:[10,20,50],
                pageNumber:1,
                height:h - 210,
                columns:[{
                    title:'资产编号',
                    field:'FACILITY_NO',
                    sortable:true
                },{
                    title:'资产名称',
                    field:'FACILITY',
                    sortable:true
                },{
                    title:'资产分类代码',
                    field:'GUOZI_SORT',
                    sortable:true
                },{
                    title:'资产分类名称',
                    field:'ASSET_TYPE',
                    sortable:true
                },{
                    title:'取得方式',
                    field:'GETTYPE',
                    sortable:true
                },{
                    title:'取得日期',
                    field:'GET_DATE',
                    sortable:true
                },{
                    title:'采购组织形式',
                    field:'PURCHASE_ID',
                    sortable:true
                },{
                    title:'备注',
                    field:'REMARK',
                    sortable:true
                }],
                queryParams:function (params) {
                    params.startDate = startDate;
                    params.endDate = endDate;
                    params.belong = belong;
                    return params;
                },
                responseHandler:function (res) {
                    console.log(res);
                    return res;
                }
            });
        }

        if(type == '3'){
            $("#export").removeAttr("disabled");
            var h = $(window).height();
            $("#list-table").bootstrapTable({
                url:'getFurnForCZB',
                method:'post',
                sidePagination: 'server',
                pagination:true,
                pageSize:20,
                pageList:[10,20,50],
                pageNumber:1,
                height:h - 210,
                columns:[{
                    title:'资产编号',
                    field:'FURN_NO',
                    sortable:true
                },{
                    title:'资产名称',
                    field:'FURN_NAME',
                    sortable:true
                },{
                    title:'资产分类代码',
                    field:'ASSET_TYPE_ID',
                    sortable:true
                },{
                    title:'资产分类名称',
                    field:'ASSET_TYPE',
                    sortable:true
                },{
                    title:'取得方式',
                    field:'GETTYPE',
                    sortable:true
                },{
                    title:'取得日期',
                    field:'GET_DATE',
                    sortable:true
                },{
                    title:'采购组织形式',
                    field:'PURCHASE_ID',
                    sortable:true
                },{
                    title:'备注',
                    field:'REMARK',
                    sortable:true
                }],
                queryParams:function (params) {
                    params.startDate = startDate;
                    params.endDate = endDate;
                    params.belong = belong;
                    return params;
                },
                responseHandler:function (res) {
                    console.log(res);
                    return res;
                }
            });
        }

        if(type == '4'){
            $("#export").removeAttr("disabled");
            var h = $(window).height();
            $("#list-table").bootstrapTable({
                url:'getBuildingForCZB',
                method:'post',
                sidePagination: 'server',
                pagination:true,
                pageSize:20,
                pageList:[10,20,50],
                pageNumber:1,
                height:h - 210,
                columns:[{
                    title:'资产编号',
                    field:'BUILDING_NO',
                    sortable:true
                },{
                    title:'资产名称',
                    field:'BUILDING_NAME',
                    sortable:true
                },{
                    title:'资产分类代码',
                    field:'ASSET_TYPE_ID',
                    sortable:true
                },{
                    title:'资产分类名称',
                    field:'ASSET_TYPE',
                    sortable:true
                },{
                    title:'取得方式',
                    field:'GETTYPE',
                    sortable:true
                },{
                    title:'取得日期',
                    field:'GET_DATE',
                    sortable:true
                },{
                    title:'采购组织形式',
                    field:'PURCHASE_ID',
                    sortable:true
                },{
                    title:'备注',
                    field:'REMARK',
                    sortable:true
                }],
                queryParams:function (params) {
                    params.startDate = startDate;
                    params.endDate = endDate;
                    params.belong = belong;
                    return params;
                },
                responseHandler:function (res) {
                    console.log(res);
                    return res;
                }
            });
        }

    });

    function clickSearch() {
        var startDate = $("#startDate").val();
        var endDate = $("#endDate").val();
        var type = $("#type").val();
        var belong = $("#belong").val();
        if(startDate == ''){
            layer.alert('请输入开始日期',{icon:2});
            return;
        }
        if(startDate == ''){
            layer.alert('请输入结束日期',{icon:2});
            return;
        }
        if(belong == '' || belong == null){
            layer.alert('请选择上级单位',{icon:2});
            return;
        }
        if(type == '' || type == null){
            layer.alert('请选择资产类型',{icon:2});
            return;
        }

        location.href = "{:url('report/facilityForCZB')}?startDate=" + startDate + "&endDate=" + endDate + "&type=" + type + "&belong=" + belong;
    }

    function clickExport() {
        var startDate = $("#startDate").val();
        var endDate = $("#endDate").val();
        var type = $("#type").val();
        var belong = $("#belong").val();

        var url = "{:url('report/exportCZBPage')}?startDate=" + startDate + "&endDate=" + endDate + "&type=" + type + "&belong=" + belong;
        var h = $(window).height()*0.8;
        var w = $(window).width()*0.8;
        layer.open({
            title:'excel导出',
            area:[w + 'px', h + 'px'],
            type:2,
            content:url
        });
    }


</script>